//
//  IvanTabBar.h
//  YuchBox
//
//  Created by Ivan on 11-9-29.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
@class IvanTabBar;

/*
@protocol IvanTabBarDelegate

//- (UIImage*) imageFor:(CustomTabBar*)tabBar atIndex:(NSUInteger)itemIndex;
//- (UIImage*) backgroundImage;
//- (UIImage*) selectedItemBackgroundImage;
//- (UIImage*) glowImage;
//- (UIImage*) selectedItemImage;
//- (UIImage*) tabBarArrowImage;

@optional
//- (void) touchUpInsideItemAtIndex:(NSUInteger)itemIndex;
- (void) touchDownAtItemAtIndex:(NSUInteger)itemIndex;
@end
*/

#define IVAN_SEL_OBJ(delegate, func_name, object) \
    if ([delegate respondsToSelector:@selector(func_name:)]) {\
        [delegate func_name:object];\
    }
@protocol IvanTabBarDelegate

@optional
- (NSInteger)showViewSequence;
- (void)viewWillAppearIvan:(BOOL)animated;
- (void)viewWillDisappearIvan:(BOOL)animated;
- (void)viewDidAppearIvan:(BOOL)animated;
- (void)viewDidDisappearIvan:(BOOL)animated;

@end

@interface IvanTabBar : UIView 
{
    NSMutableArray *_buttons;
    NSMutableArray *_items;
    UIImage        *_arrowImage;
    
    UIViewController *_delegate;
    
    UIViewController<IvanTabBarDelegate> *_currentDelegate;
    
}

@property (assign, nonatomic) CGSize barSize;
@property (strong, nonatomic) UIImage *backgroudImage;
//@property (weak, nonatomic) UIApplication *delegate;
//@property (strong, nonatomic) NSMutableArray *items;


- (id)initWithItemCount:(NSInteger)itemCount 
                  Items:(NSMutableArray *) items
 BackgroudImageFileName:(NSString *)backgroudImageFileName 
        AutoSizeByImage:(BOOL)isAutoSize 
               barFrame:(CGRect)barFrame
     ArrowImageFileName:(NSString *)arrowImageFileName
               Delegate:(UIViewController *)delegate;

- (UIImage *)imageAtIndex:(NSInteger)index;
- (UIButton*) buttonAtIndex:(NSUInteger)itemIndex width:(CGFloat)width;
- (float) horizontalLocationFor:(NSUInteger)tabIndex;
- (void) addTabBarArrowAtIndex:(NSUInteger)itemIndex;
- (void) dimAllButtonsExcept:(UIButton*)selectedButton;
- (void)touchDownAction:(UIButton *)button;

- (UIViewController *)viewControllerAtIndex:(NSInteger)index;
@end

